// 接口
export interface ListItemState {
	id: string
	url: string
	title: string
	desc: string
}

// 接口
export interface State {
	list: ListItemState[]
}

// type值
const SET_LIST = 'SET_LIST'

// action 函数
export function setList(payload: ListItemState[]) {
	return { type: SET_LIST, payload }
}

// action 类型
type ActionType = ReturnType<typeof setList>

const initState: State = {
	list: [{
		id: '123',
		url: '123',
		title: '123',
		desc: '123',
	}]
}

const reducer = (state = initState, action: ActionType) => {
	switch (action.type) {
		case SET_LIST:
			return {
				...state,
				list: action.payload
			}
		default:
			return state
	}
}


export default reducer